package javaApi.listStatus;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.io.IOException;
import java.net.URI;

public class HadoopListStatus {
    public static void main(String[] args) throws IOException {
        String uri = args[0];
        Configuration conf = new Configuration();
        FileSystem fs = FileSystem.get(URI.create(uri), conf);
        FileStatus[] fsstatus = fs.listStatus(new Path(args[0]));
        System.out.println("File List:");
        for (FileStatus status : fsstatus)
            if (status.isFile())
                System.out.println("file:" + status.getPath().toString());
            else
                System.out.println("directory:" + status.getPath().toString());
    }

}
